﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using TimKen.App;
using TimKen.DataEntity;
using TimKen.BussLogic;
using System.Collections.Generic;
namespace TimKen.Web.Admin.PAttribute
{
    public partial class Option : TimKen.App.AdminPage
    {
        POptionManager pom = new POptionManager();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindResources();
                BindData();
            }
        }

        protected void BindData()
        {
            DataSet ds = pom.GetList(PageSize, AspNetPager1.CurrentPageIndex, LanguageWhereStr);
            AspNetPager1.RecordCount = Convert.ToInt32(pom.GetListCount(LanguageWhereStr));
            this.gridPoption.DataSource = ds;
            this.gridPoption.DataBind();
        }



        protected void ok_Click(object sender, EventArgs e)
        {
            POption opcn = new POption();
            POption open = new POption();

            opcn.OptionName = txtAttrNameCN.Text;
            open.OptionName = txtAttrNameEN.Text;

            opcn.LanguageID = (int)LanguageEnum.Chinese;
            open.LanguageID = (int)LanguageEnum.English;
            
            opcn.FieldType = Convert.ToInt32(rblFieldType.SelectedValue);
            open.FieldType = Convert.ToInt32(rblFieldType.SelectedValue);

            opcn.FieldMetaData = txtFieldMetaDataCN.Text;
            open.FieldMetaData = txtFieldMetaDataEN.Text;
            IList<POption> list = new List<POption>{ opcn, open };

          
             pom.Add(list);
             Alert(GetLangString("SaveSuccessful"));

             BindData();
        }

       
        public void BindResources() { }

        protected void grdPType_RowCommand(object sender, GridViewCommandEventArgs e)
        {

        }

        protected void AspNetPager1_PageChanged(object sender, EventArgs e)
        {
            BindData();
        }
    }
}